<template>
  <div class="formContainer">
    <div class="formBox">
      <h1 class="title">身份验证</h1>
      <span>请输入用户名和密码登录，立即享受会员福利。</span>
      <div class="inputBox">
        <div class="iconBox"></div>
        <span></span>
        <input type="text" placeholder="国内手机号码/邮箱" v-model="phone"/>
      </div>
      <div class="inputBox">
        <div class="iconBox"></div>
        <span></span>
        <input type="password" placeholder="请输入密码" v-model="password"/>
      </div>
      <a href="javascript:;">
        <div class="button" @click.prevent="login">立即登陆</div>
      </a>  
      <router-link class="toRegister" to="/register">立即注册</router-link>
    </div>
  </div>
</template>

<script>
export default {
  name: 'login',
  data(){
    return{
        phone:'',
        password:''
    }
  },
  methods:{
   async login(){
      let {phone,password} = this
      try {
      const  one = await this.$store.dispatch('UserLogin',{phone,password})
        alert('登录成功')
        this.$router.push('/') 
      } catch (error) {
        alert(error.message)
      }
    }
  }
}
</script>

<style lang="less">
.formContainer {
  width: 100%;
  height: 910px;
  background-image: linear-gradient(
      hsla(0, 0%, 100%, 0.6),
      hsla(0, 0%, 100%, 0.6)
    ),
    url('./images/block_login-bg--md.jpg');
  background-size: cover;
}

.formBox {
  height: 300px;
  width: 350px;
  background: white;
  margin: 0 auto;
  position: relative;
  top: 150px;
  padding: 30px;
  box-sizing: border-box;
  position: relative;
  .title {
    font-size: 30px;
    font-style: italic;
    margin-bottom: 8px;
  }

  .inputBox {
    height: 40px;
    border: #d4d7d9 1px solid;
    box-sizing: border-box;
    margin-top: 10px;
    padding: 10px 12px;
    display: flex;
    position: relative;
    .iconBox {
      height: 18px;
      width: 25px;
      background-image: url("./images/guoqi.jpg");
      background-size: contain;
    }
    span {
      height: 25px;
      border-left: 1px solid #d4d7d9;
      margin: 0 10px;
      position: absolute;
      top: 7px;
      left: 38px;
    }
    input {
      height: 30px;
      font-size: 14px;
      border: none;
      outline: none;
      position: absolute;
      left: 58px;
      top: 3px;
    }
  }
  .button {
    height: 40px;
    background: #0082c3;
    margin-top: 15px;
    color: white;
    font-size: 16px;
    font-weight: 550;
    line-height: 40px;
    text-align: center;
  }
  .toRegister {
    position: absolute;
    right: 30px;
    bottom: 20px;
  }
}
</style>
